#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <unistd.h>
#include <stdio.h>

int main(int argc, char const *argv[])
{
    int fd;

    fd = open("test.txt", O_RDWR | O_CREAT, 0755);
    if (fd < 0)
    {
        perror("open");
        return 1;
    }

    printf("file discriptor: %d\n", fd);
    int result = close(fd);
    if (result < 0)
    {
        printf("关闭失败\n");
        perror("close");
    }

    return 0;
}
